package com.eascs.p2p.admin.manager.impl;

import java.util.Date;

import org.springframework.stereotype.Repository;

import com.eascs.p2p.admin.manager.IInvestObjectExtManager;
import com.eascs.p2p.common.dao.BaseDao;
import com.eascs.p2p.common.entity.InvestObjExtEntity;

@Repository
public class InvestObjectExtManagerImpl extends BaseDao implements IInvestObjectExtManager {

	@Override
	public String addInvestObjectExt(InvestObjExtEntity investObjExtEntity) {
		Date date = new Date();
		investObjExtEntity.setCreateTime(date);
		investObjExtEntity.setUpdateTime(date);
		
		boolean flag = this.insert(investObjExtEntity);
		if (flag == true) {
			return investObjExtEntity.getId();
		} else {
			return null;
		}
		
	}

	@Override
	public boolean updateInvestObjectExt(InvestObjExtEntity investObjExtEntity) {
		Date date = new Date();
		investObjExtEntity.setUpdateTime(date);
		String sql="update p2p_invest_obj_ext set content=? ,update_time=now() where object_id=?" ;
		
		return this.execute(sql, investObjExtEntity.getContent(),investObjExtEntity.getObjectId());
	}

	@Override
	public InvestObjExtEntity findInvestObjExtEntityDetail(String bid) {
		String sql="select * from p2p_invest_obj_ext where object_id=?" ;
		 return this.findEntity(sql, InvestObjExtEntity.class, bid);
	}


}
